package IneerClassDemo3;

public class Test2 {
    public static void main(String[] args) {
        // 1. 定义一个实现A接口的显式类（有名字）
        class AnonymousImpl implements A {
            @Override
            public void swimming() {
                System.out.println("Student swimming");
            }
        }

// 2. 创建该类的实例，赋值给A类型变量
//        A s = new AnonymousImpl();
//        A s = new A() {
//            @Override
//            public void swimming() {
//                System.out.println("Student swimming");
//            }
//        };
//        star(s);
    }
    public static void star(A s1) {
        System.out.println("star method of A");
        s1.swimming();
        System.out.println("End of star method of A");
    }

    interface A {
        public void swimming();
    }
}
//}
//class Student implements A{
//    public void swimming(){
//        System.out.println("Student swimming");
//    }
//}
//class Teacher implements A{
//    public void swimming(){
//        System.out.println("Teacher teaching");
//    }
//}

